
package com.yjh.admin.controller.chronic;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yjh.admin.entity.chronic.EquipmentUser;
import com.yjh.admin.server.chronic.EquipmentUserService;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import util.R;


/**
 * 用户设备关联表
 *
 * @author GuoBin
 * @date 2020-08-06 16:14:41
 */
@ApiOperation("用户设备关联表")
@RestController
@AllArgsConstructor
@RequestMapping("/equipmentuser")
public class EquipmentUserController {

    private final EquipmentUserService equipmentUserService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param equipmentUser 用户设备关联表
     * @return
     */
    @ApiOperation("分页查询")
    @GetMapping("/page")
    public R getEquipmentUserPage(@RequestBody Page page, EquipmentUser equipmentUser) {
        return  new R<>(equipmentUserService.page(page,Wrappers.query(equipmentUser)));
    }


    /**
     * id查询用户设备关联表
     * @param equipmentUserId id
     * @return R
     */
    @ApiOperation("通过id查询用户设备关联表")
    @GetMapping("/getById")
    public R getById(@RequestParam("equipmentUserId") Integer equipmentUserId){
        return new R<>(equipmentUserService.getById(equipmentUserId));
    }

    /**
     * 新增用户设备关联表
     * @param equipmentUser 用户设备关联表
     * @return R
     */
    @ApiOperation("新增用户设备关联表")
    @PostMapping
    public R save(@RequestBody EquipmentUser equipmentUser){
        return new R<>(equipmentUserService.save(equipmentUser));
    }

    /**
     * 修改用户设备关联表
     * @param equipmentUser 用户设备关联表
     * @return R
     */
    @ApiOperation("修改用户设备关联表")
    @PutMapping
    public R updateById(@RequestBody EquipmentUser equipmentUser){
        return new R<>(equipmentUserService.updateById(equipmentUser));
    }

    /**
     * 通过id删除用户设备关联表
     * @param equipmentUserId id
     * @return R
     */
    @ApiOperation("删除用户设备关联表")
    @DeleteMapping("/removeById")
    public R removeById(@RequestParam("equipmentUserId") Integer equipmentUserId){
        return new R<>(equipmentUserService.removeById(equipmentUserId));
    }

    /**
     * 查询全部
     * @param
     * @return R
     */
    @ApiOperation("查询全部")
    @GetMapping("/queryAll")
    public R queryAll(){
        return new R<>(equipmentUserService.list());
    }


}
